<?php

class InventarioInsumoController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		$insumo = Insumo::all();
		$inventarioinsumo = InventarioInsumo::all();
		return View::make("InventarioInsumos/inventario")->with("insumos",$insumo)->with("inventarioinsumos",$inventarioinsumo);
	}


	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		return View::make("InventarioInsumos/create");
	}


	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		$inventarioinsumo = new InventarioInsumo;
	    $inventarioinsumo ->id_insumo = Input::get('nombre');
		$inventarioinsumo ->cantidad = Input::get('cantidad');
		$inventarioinsumo ->saldo = Input::get('saldo');
		$inventarioinsumo ->observacion = Input::get('observacion');
		$inventarioinsumo->save();
        return Redirect::to('/inventario');
	}


	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		//
	}


	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		$inventarioinsumo = InventarioInsumo::find($id);
		return View::make('InventarioInsumos/edit')-> with('inventarioinsumos',$inventarioinsumo);
	}


	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		$input = Input::all(); 
		$inventarioinsumo = InventarioInsumo::find($id);
		$inventarioinsumo->saldo = $input['saldo'];
		$inventarioinsumo->cantidad = $input['cantidad'];
        $inventarioinsumo->save();              
     return Redirect::to('inventario');
	}



	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}


}
